<?php

use yii\db\Migration;
use yii\db\Schema;

class m170117_035019_CREATE_PRODUCT_DEV extends Migration
{
    public function up()
    {

        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        // 团期机票信息
        $this->createTable('product_flight', [
            "id" =>          Schema::TYPE_PK,
            "product_id"=>   Schema::TYPE_INTEGER.   "(9) NOT NULL COMMENT '所属团期航线'",
            "name"=>         Schema::TYPE_STRING.    "(128) NULL COMMENT '名称'",
            "num"=>          Schema::TYPE_INTEGER.   "(5) NULL DEFAULT '0'  COMMENT '数量'",
            "price" =>       Schema::TYPE_DECIMAL.   "(10,2) DEFAULT NULL COMMENT '价格'",
            "remark"=>       Schema::TYPE_STRING.    "(255) NULL COMMENT '备注说明'",
            "status" =>      Schema::TYPE_INTEGER.   "(1) DEFAULT  '1' COMMENT '1正常  2禁用'",
            "user_id" =>     Schema::TYPE_INTEGER.   "(10) DEFAULT '0' COMMENT '管理员编号'",
            "created_at" =>  Schema::TYPE_DATETIME.  " NULL",
            "updated_at" =>  Schema::TYPE_TIMESTAMP. " NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",
        ], $tableOptions);

        // 团期地接酒店信息
        $this->createTable('product_group', [
            "id" =>          Schema::TYPE_PK,
            "product_id"=>   Schema::TYPE_INTEGER.   "(9) NOT NULL COMMENT '所属团期航线'",
            "name"=>         Schema::TYPE_STRING.    "(128) NULL COMMENT '名称'",
            "num"=>          Schema::TYPE_INTEGER.   "(5) NULL DEFAULT '0'  COMMENT '数量'",
            "price" =>       Schema::TYPE_DECIMAL.   "(10,2) DEFAULT NULL COMMENT '价格'",
            "remark"=>       Schema::TYPE_STRING.    "(255) NULL COMMENT '备注说明'",
            "status" =>      Schema::TYPE_INTEGER.   "(1) DEFAULT  '1' COMMENT '1正常  2禁用'",
            "user_id" =>     Schema::TYPE_INTEGER.   "(10) DEFAULT '0' COMMENT '管理员编号'",
            "created_at" =>  Schema::TYPE_DATETIME.  " NULL",
            "updated_at" =>  Schema::TYPE_TIMESTAMP. " NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",
        ], $tableOptions);

        // 团期游览(岸上游)信息
        $this->createTable('product_visit', [
            "id" =>          Schema::TYPE_PK,
            "product_id"=>   Schema::TYPE_INTEGER.   "(9) NOT NULL COMMENT '所属团期航线'",
            "name"=>         Schema::TYPE_STRING.    "(128) NULL COMMENT '名称'",
            "num"=>          Schema::TYPE_INTEGER.   "(5) NULL DEFAULT '0'  COMMENT '数量'",
            "price" =>       Schema::TYPE_DECIMAL.   "(10,2) DEFAULT NULL COMMENT '价格'",
            "remark"=>       Schema::TYPE_STRING.    "(255) NULL COMMENT '备注说明'",
            "status" =>      Schema::TYPE_INTEGER.   "(1) DEFAULT  '1' COMMENT '1正常  2禁用'",
            "user_id" =>     Schema::TYPE_INTEGER.   "(10) DEFAULT '0' COMMENT '管理员编号'",
            "created_at" =>  Schema::TYPE_DATETIME.  " NULL",
            "updated_at" =>  Schema::TYPE_TIMESTAMP. " NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",
        ], $tableOptions);

    }

    public function down()
    {
        echo "m170117_035019_CREATE_PRODUCT_DEV cannot be reverted.\n";
        $this->dropTable('product_flight');
        $this->dropTable('product_group');
        $this->dropTable('product_visit');
        return false;
    }

}
